#
#
# @param num int整型一维数组
# @return int整型二维数组
#
class Solution:
    def permute(self, num):
        # write code here
        # 二维空数组
        res = []
        self.permutation(res, num, 0)
        return res

    def permutation(self, res, num, idx):
        if (len(num)-1 == idx):
            # 数组要复制
            # res.append(num[0:len(num)])
            res.append(num)
            return
        for i in range(idx, len(num)):
            if (num[i] != num[idx]):
                num[i], num[idx] = num[idx], num[i]
                self.permutation(res, num, idx + 1)
                num[i], num[idx] = num[i], num[idx]
            else:
                self.permutation(res,num,idx+1)


s = Solution()
res = s.permute([1,2,3])
print(res)